<?php
/**
 * 
 * 
 * $Rev: 3 $
 * $Author: thejahweh $
 * $Date: 2010-06-30 13:10:01 +0000 (Wed, 30 Jun 2010) $
 * $Id: role.class.php 3 2010-06-30 13:10:01Z thejahweh $
 * $URL: http://allone.googlecode.com/svn/trunk/plugins/rbac/role.class.php $
 * @author: Adrian Liechti <info@jahweh.ch>
 * @copyright: 2010 Adrian Liechti, GPL3 and CC3 BY-SA
 */

class role {
	
	public $id;
	public $name;
	public $description;
	public $isLoaded = false;
	
	public function __construct ($id = false) {
		if ($id !== false) $this->getRole($id);
	}
	
	public function getRole ($id) {
		global $db;
		$role_q = $db->query("
			SELECT *
			FROM roles
			WHERE
				role_id = ".$db->quote($id)."
			LIMIT 1;");
		return $this->getRoleBySQL($role_q);
	}
	
	private function getRoleBySQL ($role_q) {
		global $db;
		if ($role_q !== false) {
			$role				= $role_q->fetch();
			$this->id			=& $role['role_id'];
			$this->name			=& $role['name'];
			$this->description	=& $role['description'];
			return $this->isLoaded = true;
		} else {
			u::o($db->error, 'user:getRole', 1);
			return $this->isLoaded = false;
		}
	}
	
	public function newRole () {}
	
}
?>